package com.zywl.web.utils.tags;

import com.zywl.utils.utils.Constants;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import java.util.List;

public class ButtonContants extends TagSupport {
    private static final long serialVersionUID = 1567L;
    private String btnStr;

    @Override
    public int doStartTag() throws JspException {
        HttpSession session = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()
                .getSession();
        List<String> pathes = (List<String>) session.getAttribute(Constants.RES_SESSION_KEY_BUT);
        for (String path : pathes) {
            if (path != null && path.contains(btnStr)) {
                return TagSupport.EVAL_BODY_INCLUDE;
            }
        }
        return TagSupport.SKIP_BODY;
    }

    public String getBtnStr() {
        return btnStr;
    }

    public void setBtnStr(String btnStr) {
        this.btnStr = btnStr;
    }

}